<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
    <title>编辑</title>
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-test-edit" action="#"
          th:action="@{/admin/test/edit}" th:object="${test}">
        <input type="hidden" name="id" th:value="${test.id}"/>
                <div class="row cl">
                    <label class="form-label col-xs-2 col-sm-2"><span
                                class="c-red">*</span>名字：</label>
                            <div class="formControls col-xs-10 col-sm-10">
                                <input type="input-text" class="input-text" th:value="${test.name}" name="name"  placeholder="修改名字" id="name"/>
                            </div>
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-2 col-sm-2"><span
                                class="c-red">*</span>文本：</label>
                            <div class="formControls col-xs-10 col-sm-10">
                                <script id="editor" th:text="${test.text}" name="text" autofocus type="text/plain" style="height: 500px">
                                </script>
                            </div>
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-2 col-sm-2"><span
                                class="c-red">*</span>时间：</label>
                            <div class="formControls col-xs-10 col-sm-10">
                                <input type="input-text" class="input-text timeSpace" readonly="readonly" autocomplete="off" th:value="${#temporals.format(test.date, 'yyyy-MM-dd HH:mm:ss')}" name="date" placeholder="请选择时间"/>
                            </div>
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-2 col-sm-2"><span
                                class="c-red">*</span>file：</label>
                            <div class="formControls col-xs-10 col-sm-10">
                                <input type="input-text" class="input-text" th:value="${test.file}" name="file"  placeholder="修改file" id="file"/>
                            </div>
                    </div>
                </div>
        <div class="row cl">
            <div class="col-xs-3 col-sm-3 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" id="subbtn" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"/>
                <input class="btn radius" id="reset" type="reset" value="&nbsp;&nbsp;重置&nbsp;&nbsp;"/>
            </div>
        </div>
    </form>
</article>
<!--_footer 作为公共模版分离出去-->
<div th:replace="_footer :: footerjs"></div>
<div th:replace="_ueditor :: ueditor"></div>
<!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script>
    $(function () {
        $("#form-test-edit").validate({
            rules: {
        name:
        {
            required: true,
        },
        text:
        {
            required: true,
        },
        date:
        {
            required: true,
        },
        file:
        {
            required: true,
        },
    },
        onkeyup:false,
            debug
    :
        true,
            success
    :
        "valid",
            submitHandler
    :

        function (form) {
            $(form).ajaxSubmit({
                type: 'POST',
                url: "/admin/test/edit",
                success: function (data) {
                    if (data.code == "0") {
                        layer.designMsg('编辑成功!', 1, function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload();
                            parent.layer.close(index);
                        });
                    } else {
                        layer.designMsg('编辑失败!');
                    }
                },
                error: function () {
                    layer.designMsg('编辑异常!', 5);
                }
            });
        }
    })
        ;
    });

    lay('.timeSpace').each(function(){
        laydate.render({
            elem: this
            ,trigger: 'click'
        });
    });

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>